#include <iostream>
using namespace std;
class Rectangle {
private:
  int m_width;
  int m_height;
  int m_area;
  static int ms_area;

public:
  Rectangle(int w, int h) {
    this->m_width = w;
    this->m_height = h;
    m_area += (this->m_width * this->m_height);
    ms_area += (this->m_width * this->m_height);
  }
  void GetSum() { cout << "m_sSum = " << m_area << endl; }
  static void StaticGetSum() { cout << "m_sSum = " << ms_area << endl; }
};
// 初始化类的静态成员变量
int Rectangle::ms_area = 0;
int main() {
  cout << "Rectangle 类的大小：" << sizeof(Rectangle) << endl;
  Rectangle *rect = new Rectangle(3, 4);
  rect->GetSum();
  rect->StaticGetSum();
  cout << "Rectangle 实例的大小：" << sizeof(*rect) << endl;
  Rectangle *rect2 = new Rectangle(6, 9);
  rect2->GetSum();
  rect2->StaticGetSum(); //此时初始化static变量
  cout << "sizeof(rect2) = " << sizeof(*rect2) << endl;

  Rectangle::StaticGetSum(); //通过类名访问
  delete rect;
  delete rect2;
  return 0;
}
